package ThreadDemo;

public class ThreadDemo05 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread("蔡徐坤线程"){
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        System.out.println("线程名:"+t.getName());
        System.out.println("线程ID:"+t.getId());
        System.out.println("线程优先级:"+t.getPriority());
        System.out.println("是否是后天线程:"+t.isDaemon());
        System.out.println("线程是否存活:"+t.isAlive());
        System.out.println("线程是否被中断："+t.isInterrupted());
        t.start();
        while(t.isAlive()){
            System.out.println("蔡徐坤线程正在运行");
            System.out.println("线程是否存活:"+t.isAlive());
            System.out.println("线程是否被中断："+t.isInterrupted());
            Thread.sleep(1000);
        }
    }
}
